
#include "compile.hpp"
#include <iostream>
#include "runner.hpp"
#include <locale>
#include "compile_run.hpp"
#include "../public/httplib.h"
using namespace ns_compile_and_run;
using namespace httplib;
void Usage(const std::string &proc)
{
  std::cerr << "Usage" << "\n\r" << proc << " :port" << std::endl;
}
int main(int argc, char *argv[])
{
  if (argc != 2)
  {
    Usage(argv[0]);
    return 1;
  }
  Server svr;
  svr.listen("0.0.0.0", atoi(argv[1])); // 启动服务
  svr.Post("/compile_and_run", [](const Request &req, Response &resp)
           {
      std::string in_json=req.body;
      std::string out_json;
      CompileAndRun::Start(in_json,&out_json);
      resp.set_content(out_json,"application/json;charset=utf-8"); });
  // svr.listen("0.0.0.0", atoi(argv[1])); // 启动服务

  return 0;
}